home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / INFO / DOSTIPS3.ZIP / DOSSET.TXT < prev    next >
Text File  |  1985-11-24  |  7KB  |  193 lines

  1.                        Enhancing PC-DOS
  2.         (PC Magazine Vol 3 No 14 July 24, 1984 by G. Weissman)
  3.  
  4. NOTE: This doesn't work with DOS 2.1; try it with DOS 2.0 someday.
  5.  
  6.      The DOS SET command lets you create a list of text symbols (or 
  7. variables) called the "environment," which is held in a reserved 
  8. portion of memory.  These symbols can represent longer commands or
  9. path names.  The variables and their definitions listed in the
  10. environment can be interpreted by any program that was designed with
  11. this feature in mind.  DOS 2.0 documentation includes instructions that
  12. can be used to locate the environment.  Little use is made of the
  13. environment's capability in DOS 2.0 itself except for three symbols
  14. that control system characteristics:  COMSPEC for the name of the
  15. command interpreter; PATH for the list of directories where executable
  16. files can be found; and PROMPT for the current definition of the system 
  17. prompt.
  18.      To make better use of the environment, you must make changes to 
  19. the DOS command interpreter, the link between a user and the operating 
  20. system.  Usually COMMAND.COM is the program used as the command 
  21. interpreter, so much so that COMMAND.COM's own commands (such as COPY, 
  22. TYPE and DIR) are all that users know.  You send commands from batch 
  23. files or the keyboard to the command interpreter, and it responds by 
  24. loading and starting other programs or performing tasks such as 
  25. renaming or deleting files.
  26.      There were three parts to the modification: modify the COMMAND.COM 
  27. file to give it extra space, which you must do; finding where the input 
  28. lines are analyzed by COMMAND.COM; and inserting new code into 
  29. COMMAND.COM that intercepts the analysis process to substitute symbol 
  30. values for symbol names.  (Only the first and third procedures are 
  31. necessary here.)
  32.      The substitution of symbol values for names using the SET command 
  33. is a powerful tool.  Assume you have two file directories: 
  34. TAXES\DATA\MARCH\EXPNS, and BUDGET\REPORTS\MARCH\TAXES.  If you must 
  35. refer to different files within these two directories, you can use the 
  36. environment feature to reduce the keystrokes in these names by 
  37. initially typing:
  38.           SET D1=\TAXES\DATA\MARCH\EXPNS\
  39. and
  40.           SET D2=\BUDGET\REPORTS\MARCH\TAXES\.
  41. Then you can type 'D1' and 'D2' (including the single-quotation marks) 
  42. as part of any DOS command and get the same results as if you'd typed 
  43. the directory names in full.  DOS will continue to interpret these 
  44. abbreviations until you turn off the computer or enter SET D1= to erase 
  45. the symbol assignment.  This procedure is like using variables that 
  46. represent values rather than the values themselves in a BASIC program. 
  47. (Without this capability, BASIC would be useless as a programming 
  48. language.)
  49.      This modification of the environment permits you to distinguish 
  50. between characters in a DOS command that are symbols and those that are 
  51. to be interpreted normally.  A symbol name must be inside single 
  52. quotation marks which is a good character for this purpose -- it has no 
  53. reserved meaning in DOS, it rarely appears in file names, and it's easy 
  54. to type.
  55.      (The remainder of this article describes how the initialization 
  56. process works after COMMAND.COM is loaded into RAM by DOS.  The next 
  57. article describes the rest of the process.)
  58.  
  59. -----------------------------------------------------------------
  60.                         Get SET for Speed
  61.   (from PC Magazine Vol 3 No 15 August 7, 1984 by G. Weissman)
  62.  
  63.      The first step is to add 1,024 bytes to the COMMAND.COM program 
  64. to insert modified code.  These 1,024 bytes are more than enough for
  65. the changes in this article, so you can use the rest to add
  66. improvements of your own.
  67.      Using a copy of COMMAND.COM, run DEBUG and use the ASSEMBLE 
  68. command to expand COMMAND.COM:
  69.  
  70. - A 1ED
  71. xxxx:01ED ADD DX,3270
  72. xxxx:01F1 [Enter]
  73. - A 3AD
  74. xxxx:03AD CMP BX,3B0
  75. xxxx:03B1 [Enter]
  76. - A 3CD
  77. xxxx:03CD SUB BX,390
  78. xxxx:03D1 [Enter]
  79. - A 691
  80. xxxx:0691 MOV CX,37BE
  81. xxxx::0694 [Enter]
  82. - A 6A9
  83. xxxx:06A9 CMP CX,37BE
  84. xxxx:06AD [Enter]
  85. - A C9D
  86. xxxx:0C9D SUB AX,390
  87. xxxx:0CA0 [Enter]
  88. - A 140B
  89. xxxx:140B CALL 4030
  90. xxxx:140E [Enter]
  91. - M 4030 4580 4430
  92. - F 4030 442F 0
  93. - R CX
  94. CX 4500
  95. :4900
  96. - N COMMAND.TMP
  97. - W
  98. writing 4900 bytes
  99. - Q
  100.  
  101.      You created COMMAND.TMP, a version of COMMAND.COM with space 
  102. between its data work area and the EXEC handler.  The next step is to 
  103. create a subroutine for symbol substitution via the command processor's 
  104. environment table.  This subroutine will be located at offset 4030 h in 
  105. the COMMAND.COM file.
  106.      Run DEBUG on COMMAND.TMP and enter the following:
  107.           
  108. -A 4030
  109. xxxx:4030 MOV SI,2B8B
  110. xxxx:4033 MOV BX,3000
  111. xxxx:4036 XOR DX,DX
  112. xxxx:4038 MOV ES,[2CA0]            
  113. xxxx:403C ES:
  114. xxxx:403D MOV ES,[0B1C]
  115. xxxx:4041 LODSB
  116. xxxx:4042 CMP AL,27
  117. xxxx:4044 JZ 4065
  118. xxxx:4046 MOV [BX],AL
  119. xxxx:4048 INC BX
  120. xxxx:4049 CMP AL,0D
  121. xxxx:404B JNZ 4041
  122. xxxx:404D PUSH CS
  123. xxxx:404E POP ES
  124. xxxx:404F MOV CX,0886
  125. xxxx:4052 OR DX,DX
  126. xxxx:4054 JZ 4063
  127. xxxx:4056 MOV SI,3000
  128. xxxx:4059 MOV DI,2B8B
  129. xxxx:405C MOVSB
  130. xxxx:405D CMP BY [DI-01],0D
  131. xxxx:4061 JNZ 405C
  132. xxxx:4063 JMP CX
  133. xxxx:4065 MOV DX,SI
  134. xxxx:4067 MOV DI,0001
  135. xxxx:406A DEC DI
  136. xxxx:406B MOV SI,DX
  137. xxxx:406D LODSB
  138. xxxx:406E CMP AL,0D
  139. xxxx:4070 JZ 4046
  140. xxxx:4072 CMP AL,27
  141. xxxx:4074 JNZ 4088
  142. xxxx:4076 MOV AL,3D
  143. xxxx:4078 SCASB
  144. xxxx:4079 JNZ 4095
  145. xxxx:407B ES:
  146. xxxx:407C MOV AL,[DI]
  147. xxxx:407E OR AL,AL
  148. xxxx:4080 JZ 4041
  149. xxxx:4082 MOV [BX],AL
  150. xxxx:4084 INC BX
  151. xxxx:4085 INC DI
  152. xxxx:4086 JMP 407B
  153. xxxx:4088 CMP AL,61
  154. xxxx:408A JB 4092
  155. xxxx:408C CMP AL,7A
  156. xxxx:408E JA 4092
  157. xxxx:4090 AND AL,5F
  158. xxxx:4092 SCASB
  159. xxxx:4093 JZ 406D
  160. xxxx:4095 DEC SI
  161. xxxx:4096 XOR CX,CX
  162. xxxx:4098 MOV AL,CL
  163. xxxx:409A DEC CX
  164. xxxx:409B REPNZ
  165. xxxx:409C SCASB
  166. xxxx:409D SCASB
  167. xxxx:409E JNZ 406A
  168. xxxx:40A0 LODSB
  169. xxxx:40A1 CMP AL,27
  170. xxxx:40A3 JZ 4041
  171. xxxx:40A5 CMP AL,0D
  172. xxxx:40A7 JZ 4046
  173. xxxx:40A9 JMP 40A0
  174. xxxx:40AC [Enter]
  175. - W
  176. writing 4900 bytes
  177. - Q
  178.  
  179.      The final step is to copy the modified command processor over the 
  180. old COMMAND.COM.  Enter:
  181.           A>COPY COMMAND.TMP COMMAND.COM
  182. Reboot the system, loading the new version of COMMAND.COM, and see if 
  183. everything operates normally.
  184.      After you make sure your modifications have done no harm, you can 
  185. test it by entering the command:
  186.           A>DIR 'COMSPEC'
  187. The display should say, "COMMAND.COM 18688" followed by the date and 
  188. time.  Now enter:
  189.      A>SET X=Hello. This is proof that the substitution works.
  190. After that, enter:
  191.           A>ECHO 'X'
  192. and the screen should display the message, "Hello. This is ..."
  193.